package com.project.lx.gettxtfilename.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.project.lx.baseproject.base.BaseActivity;
import com.project.lx.gettxtfilename.AnimatorActivity;
import com.project.lx.gettxtfilename.DetailsActivity;
import com.project.lx.gettxtfilename.GetFileActivity;
import com.project.lx.gettxtfilename.QRcode.QRcodeActivity;
import com.project.lx.gettxtfilename.R;
import com.project.lx.gettxtfilename.Receiver.ReceiverActivity;
import com.project.lx.gettxtfilename.RecycleView.RecViewActivity;
import com.project.lx.gettxtfilename.RecycleView.RecycleView2Activity;
import com.project.lx.gettxtfilename.md.MainActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class HomeActivity extends BaseActivity {

    @BindView(R.id.recy_main)
    RecyclerView recyMain;

    MainAdapter adapter;

    List<MainItem> list;

    String[] TITLES = {"MainActivity", "QRcodeActivity", "RecViewActivity",
            "RecycleView2Activity", "AnimatorActivity", "DetailsActivity",
            "GetFileActivity", "ReceiverActivity"};

    Class[] CLASS = {MainActivity.class, QRcodeActivity.class, RecViewActivity.class,
            RecycleView2Activity.class, AnimatorActivity.class, DetailsActivity.class,
            GetFileActivity.class, ReceiverActivity.class};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void initRootView() {
        setContentView(R.layout.activity_home);
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        RecycleViewUtils.getVerticalLayoutManager(this, recyMain);

        list = new ArrayList<>();

        for (int i = 0; i < TITLES.length; i++) {
            MainItem item = new MainItem();
            item.setTitle(TITLES[i]);
            item.setCls(CLASS[i]);
            list.add(item);
        }

        adapter = new MainAdapter(R.layout.item_main, list);
        recyMain.setAdapter(adapter);

        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                MainItem item = (MainItem) adapter.getItem(position);
                startActivity(new Intent(HomeActivity.this, item.getCls()));
            }
        });
    }

    @Override
    public void initListener() {

    }
}
